// #define print(...)
#define map_t unordered_map
class Solution {
public:
    int countPairs(vector<int>& deliciousness) {
        int res = 0;
        map_t<int, int> cnt;
        auto maxSum = *max_element(deliciousness.begin(), deliciousness.end()) << 1;
        for(auto &i:deliciousness){
            for(int meal = 1; meal <= maxSum; meal <<= 1){
                if(cnt.count(meal-i)){
                    res = (res + cnt[meal-i]) % 1000000007;
                    print(i, " + ", meal-i, "(", cnt[meal-i], ") = ", meal, "\n")
                }
            }
            cnt[i]++;
        }
        return res;
    }
};
